package utils;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.stream.Stream;

public class FileUtils {
    public static void createDirectoryIfNotExists(String directoryPath) throws IOException {
        Path path = Paths.get(directoryPath);
        if (!Files.exists(path)) {
            Files.createDirectories(path);
        }
    }

    public static Stream<File> listFiles(String directoryPath) throws IOException {
        return Files.list(Paths.get(directoryPath))
                .map(Path::toFile)
                .filter(File::isFile);
    }
}